from typing import List


# Definition for Employee.
class Employee:
    def __init__(self, id: int, importance: int, subordinates: List[int]):
        self.id = id
        self.importance = importance
        self.subordinates = subordinates


class Solution:
    def getImportance(self, employees: List['Employee'], id: int) -> int:
        employees_map = {}
        for employee in employees:
            employees_map[employee.id] = employee
        sum = employees_map[id].importance
        for employee in employees_map[id].subordinates:
            sum += self.getImportanceWithMap(employees_map, employee)
        # print(id, sum)
        return sum

    def getImportanceWithMap(self, employees_map, id) -> int:
        sum = employees_map[id].importance
        for employee in employees_map[id].subordinates:
            sum += self.getImportanceWithMap(employees_map, employee)
        # print(id, sum)
        return sum


if __name__ == '__main__':
    nums = [
        Employee(1, 5, [2, 3]),
        Employee(2, 3, []),
        Employee(3, 3, []),
    ]
    s = Solution()

    print(s.getImportance(nums, 1))
